﻿using System;
using System.Collections.Generic;
using System.Text;
using AMS.DataAccess.Trademark.Interfaces;
using System.Data;
using AMS.DataAccess.Common;
using AMS.DataAccess.Sql;

namespace AMS.DataAccess.Trademark
{
    public class DocManager : IDocManager
    {
        public DataTable GetAllDocuments(Filters.DocFilter filter)
        {
            SqlBuilder sql = new SqlBuilder();
            sql.Add("SELECT * FROM TT_Document");
            if (filter != null)
            {
                sql.Add("    WHERE 1=1");
                if (filter.Language != null)
                {
                    sql.Add("    AND Lan ", filter.Language.ToString());
                }
                if (filter.Destination != null)
                {
                    sql.Add("    AND Destination ", filter.Destination.ToString());
                }
                if (filter.DocName != null)
                {
                    sql.Add("    AND DocName ", filter.DocName.ToString());
                }
            }

            var ds = SqlDBHelper.Query(sql.ToString());
            AMS.DataAccess.SqlDebugger.WriteLine(sql);
            return ds.Tables[0];
        }
    }
}
